﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：李刚 
    //
    // 文件名：RelationHospital.cs
    // 文件功能描述：企业的某条配送产品相关要配送的医疗机构
    // 创建标识：李刚2009-05-18
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using System.Collections.Generic;
using HZ.DrugTrade.Model.Enum;

namespace HZ.DrugTrade.Web.Enterprise.RelationQuery
{
    public partial class RelationHospital : BasePage
    {
        public RelationHospital()
        {
            this.ModuleNo = Module.产品库管理.ToString();
        }

        IBLL_Distribution id = Factory.BLL_Distribution();
        IBLL_ProcurementBasic pbCtrl = Factory.BLL_ProcurementBasic();
        IBLL_HospitalProcureCatalog ihp = Factory.BLL_HospitalProcureCatalog();

        protected void Page_Load(object sender, EventArgs e)
        {
            string procureCatalogId = Request.QueryString["procureCatalogId"];

            HZ.DrugTrade.Model.View.ProcureCatalog procureCatalog = pbCtrl.GetProcureCatalogByID(procureCatalogId);
            if (procureCatalog == null)
            {
                PageError("采购产品不存在！", this.ReturnUrl);
            }

            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["CompanyID_PS"]))
                {
                    hfdHospitalInfo.Value = Request.QueryString["CompanyID_PS"];
                }
                BindAllHospitalList();
            }
        }

        /// <summary>
        /// 绑定相关的医疗机构列表
        /// </summary>
        private void BindAllHospitalList()
        {
            //显示产品信息
            string procureCatalogId = Request.QueryString["procureCatalogId"];
            string areaId = Request.QueryString["areaId"];
            HZ.DrugTrade.Model.View.ProcureCatalog procureCatalog = pbCtrl.GetProcureCatalogByID(procureCatalogId);
            this.lblGoodsName.Text = procureCatalog.GoodsName;
            this.lblJx.Text = procureCatalog.Material;
            this.lblGg.Text = procureCatalog.Outlookc;
            this.lblCompanyName_SC.Text = procureCatalog.CompanyName_SC;
            this.lblCompanyName_ZB.Text = procureCatalog.CompanyName_TB;
            this.lblBidPrice.Text = (procureCatalog.ProcurePrice.Value == 0) ? "NA" : procureCatalog.ProcurePrice.Value.ToString("0.00");

            //查询相关医疗机构，加入了地区条件
            int totalCount;
            Model.Query.HospitalProcureCatalog qHospitalCatalog = new HZ.DrugTrade.Model.Query.HospitalProcureCatalog()
            {
                ProcureCatalogID = procureCatalogId,
                AreaID = areaId,
                Companyid_Ps = CurrentAccount.GetUser().Org.OrgID,
                SortFields = "HospitalName asc"
            };
            IList<Model.View.HospitalProcureCatalog> hosiptalCatalogList = ihp.GetHospitalProcureCatalog(qHospitalCatalog, 1, 0, out totalCount);

            gvwHospital.DataSource = hosiptalCatalogList;
            gvwHospital.DataBind();

        }
    }
}
